package com.talent.jiwen.home;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.alibaba.fastjson.JSON;
import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
import com.bigkoo.pickerview.listener.OnOptionsSelectListener;
import com.bigkoo.pickerview.view.OptionsPickerView;
import com.luck.picture.lib.PictureSelector;
import com.luck.picture.lib.config.PictureConfig;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.tools.PictureFileUtils;
import com.talent.jiwen.HomeFragment;
import com.talent.jiwen.IndexActivity;
import com.talent.jiwen.MainActivity;
import com.talent.jiwen.R;
import com.talent.jiwen.base.BaseActivity;
import com.talent.jiwen.http.common.ActivityLifeCycleEvent;
import com.talent.jiwen.http.common.ApiFactory;
import com.talent.jiwen.http.common.HttpUtil;
import com.talent.jiwen.http.common.ProgressSubscriber;
import com.talent.jiwen.http.result.CouponListResult;
import com.talent.jiwen.http.result.SaveOrderResult;
import com.talent.jiwen.my.CouponSelectActivity;
import com.talent.jiwen.my.RechargeActivity;
import com.talent.jiwen.teacher.CourseFragment;
import com.talent.jiwen.teacher.CourseListFragment;
import com.talent.jiwen.training.data.IdNameBean;
import com.talent.jiwen.ui.widgets.ChooseTeachDialog;
import com.talent.jiwen.ui.widgets.LoadingDialog;
import com.talent.jiwen.ui.widgets.NoEmojiEditText;
import com.talent.jiwen.util.Constant;
import com.talent.jiwen.util.ImageUtil;
import com.talent.jiwen.util.LogUtil;
import com.talent.jiwen.util.MaterialDialogUtil;
import com.talent.jiwen.util.SPConstant;
import com.talent.jiwen.util.SPUtil;
import com.talent.jiwen.util.Validators;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import org.greenrobot.eventbus.EventBus;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.OnClick;
import rx.Observable;

public class AddProblemNewActivity extends BaseActivity {
    @BindView(R.id.subjectRecyclerView)
    RecyclerView subjectRecyclerView;
    @BindView(R.id.timeSelectLayout)
    RelativeLayout timeSelectLayout;
    @BindView(R.id.timeClockIv)
    ImageView timeClockIv;
    @BindView(R.id.teachTimeTv)
    TextView teachTimeTv;
    @BindView(R.id.contentEt)
    NoEmojiEditText contentEt;
    @BindView(R.id.recyclerView)
    RecyclerView recyclerView;
    @BindView(R.id.addIv)
    ImageView addIv;
    @BindView(R.id.oneByOneTv)
    TextView oneByOneTv;
    @BindView(R.id.oneByOneIv)
    ImageView oneByOneIv;
    @BindView(R.id.oneByOneLayout)
    RelativeLayout oneByOneLayout;
    @BindView(R.id.multiTv)
    TextView multiTv;
    @BindView(R.id.multiIv)
    ImageView multiIv;
    @BindView(R.id.MultiLayout)
    RelativeLayout MultiLayout;
    @BindView(R.id.teacherNameTv)
    TextView teacherNameTv;
    @BindView(R.id.attentionTv)
    TextView attentionTv;
    @BindView(R.id.teacherLayout)
    RelativeLayout teacherLayout;
    @BindView(R.id.askLayout)
    RelativeLayout askLayout;
    @BindView(R.id.couponLayout)
    RelativeLayout couponLayout;
    @BindView(R.id.couponTv)
    TextView couponTv;

    //开课方式
    private static final int TYPE_ONE_BY_ONE = 1;//1对1教学
    private static final int TYPE_MULTI = 2;//多人教学
    private int teachType = TYPE_ONE_BY_ONE;
    //课程时间
    private static final int TEACH_NOW = 1;//现在
    private static final int TEACH_ORDER = 2;//预约
    private String answerTime = "";
    private int teachTimeType = TEACH_NOW;

    //老师类型
    private int requiredTeacherType = 0;//0：全部 1：正规教师 2：实习教师

    private List<LocalMedia> pathList = new ArrayList<>();//选择的照片路径
    private List<String> imgList = new ArrayList<>();//压缩后的图片显示路径

    public static final int MAX_IMG = 3;

    private static final String PARAM_GROUP_ID = "param.group.id";
    private static final String PARAM_COUPON_COUNT = "param.coupon.count";
    private static final String PARAM_APPOINT_TEACHER_ID = "param.appoint.teacher.id";
    private static final String PARAM_HAS_ORDER_NOW = "param.has.order.now";
    private static final String PARAM_ORDER_TYPE = "param.order.type";
//    private static final String PARAM_IMG_PATH_LIST = "param.img.path.list";
    private static final String PARAM_COUPON = "param.coupon";

    public static final int ORDER_TYPE_NORMAL = 0;//正常订单
    public static final int ORDER_TYPE_FREE  = 1;//体验/免费订单
    private int orderType;//订单类型，0：普通订单，1：免单型订单
    private int couponCount;//优惠券数量
    private String groupId;//群组Id
    private String appointTeacherId; //指定老师Id
    private boolean hasOrderNow = false;
    private CouponListResult.Coupon coupon;

    private int subjectId;
    private String questionImages = "";

    public static final int REQUEST_CODE_COUPON = 111;//选择优惠券

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_add_problem_new;
    }

    @Override
    public String titleName() {
        return getString(R.string.add_problem);
    }

    @Override
    protected void initData() {

        groupId = getIntent().getStringExtra(PARAM_GROUP_ID);
        couponCount = getIntent().getIntExtra(PARAM_COUPON_COUNT , 0);
        orderType = getIntent().getIntExtra(PARAM_ORDER_TYPE , ORDER_TYPE_NORMAL);
        appointTeacherId = getIntent().getStringExtra(PARAM_APPOINT_TEACHER_ID);
        hasOrderNow = getIntent().getBooleanExtra(PARAM_HAS_ORDER_NOW , false);
//        String pathListJson = getIntent().getStringExtra(PARAM_IMG_PATH_LIST);
        String couponStr = getIntent().getStringExtra(PARAM_COUPON);

        if (couponCount > 0){
            couponLayout.setVisibility(View.VISIBLE);
            couponTv.setText("共" + couponCount + "张优惠券可用");
        }else{
            couponLayout.setVisibility(View.GONE);
        }

        //提问前是否使用了优惠券，判断订单类型
        if (!Validators.isEmpty(couponStr)){
            coupon = JSON.parseObject(couponStr , CouponListResult.Coupon.class);
            couponTv.setText(coupon.getCouponName());

            orderType = coupon.getDiscountType();//免单
        }else{
            orderType = ORDER_TYPE_NORMAL;
        }

        //如果之前有图片传入，设置图片数据
//        if (!Validators.isEmpty(pathListJson)){
//            pathList.clear();
//            pathList.addAll(JSON.parseArray(pathListJson , LocalMedia.class));
//            imgList.clear();
//            for (LocalMedia localMedia : pathList) {
//                imgList.add(localMedia.getCompressPath());
//            }
//            if (imgList.size() == 3){
//                addIv.setVisibility(View.GONE);
//            }else{
//                addIv.setVisibility(View.VISIBLE);
//            }
//        }

        //判断是否有正在进行中的订单
        if (hasOrderNow){
            attentionTv.setVisibility(View.VISIBLE);
        }else{
            attentionTv.setVisibility(View.GONE);
        }

        //学科选择
        final List<IdNameBean> subjectList = new ArrayList<>();
        for (Map.Entry<Integer, String> entry : Constant.subjectMap.entrySet()) {
            IdNameBean bean = new IdNameBean(entry.getKey() ,entry.getValue());
            subjectList.add(bean);
        }

        //默认选择第一个学科
        subjectId = subjectList.get(0).getId();
        subjectList.get(0).setSelected(true);

        LinearLayoutManager subjectLayoutManager = new LinearLayoutManager(this);
        subjectLayoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        subjectRecyclerView.setLayoutManager(subjectLayoutManager);
        subjectRecyclerView.setAdapter(new CommonAdapter<IdNameBean>(AddProblemNewActivity.this , R.layout.item_subject_sel , subjectList){

            @Override
            protected void convert(ViewHolder holder, final IdNameBean idNameBean, int position) {
                TextView subjectTv = holder.getView(R.id.subjectTv);
                View divider = holder.getView(R.id.divider);

                subjectTv.setText(idNameBean.getName());
                if (idNameBean.isSelected()){
                    subjectTv.setTextColor(ContextCompat.getColor(AddProblemNewActivity.this , R.color.common_app_color));
                    divider.setVisibility(View.VISIBLE);
                }else{
                    subjectTv.setTextColor(ContextCompat.getColor(AddProblemNewActivity.this , R.color.text_gray_6));
                    divider.setVisibility(View.GONE);
                }

                holder.itemView.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        subjectId = idNameBean.getId();
                        idNameBean.setSelected(true);
                        for (IdNameBean bean : subjectList){
                            if (bean.getId() != idNameBean.getId()){
                                bean.setSelected(false);
                            }
                        }
                        notifyDataSetChanged();
                    }
                });
            }
        });

        //图片
        LinearLayoutManager layoutManager = new LinearLayoutManager(this);
        layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        recyclerView.setLayoutManager(layoutManager);
        recyclerView.setAdapter(new CommonAdapter<String>(AddProblemNewActivity.this, R.layout.item_add_problem_img_new, imgList) {
            @Override
            protected void convert(ViewHolder holder, String s, final int position) {
                ImageView imgIv = (ImageView) holder.getView(R.id.imgIv);
                ImageUtil.loadCorner4Image(AddProblemNewActivity.this, s, imgIv);

                imgIv.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        ImageUtil.picturePreview(AddProblemNewActivity.this , position  , pathList);
                    }
                });
            }

        });

    }

    @OnClick({R.id.timeSelectLayout ,  R.id.addIv, R.id.oneByOneLayout, R.id.MultiLayout
            , R.id.teacherLayout, R.id.askLayout , R.id.couponLayout})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.timeSelectLayout:
                showWheelPicker(getTimeList() , null);
                break;
            case R.id.addIv:
                ImageUtil.pickPhoto(AddProblemNewActivity.this , MAX_IMG  , pathList , true);
                break;
            case R.id.oneByOneLayout:
                teachType = TYPE_ONE_BY_ONE;

                oneByOneTv.setTextColor(ContextCompat.getColor(AddProblemNewActivity.this , R.color.common_app_color));
                oneByOneIv.setImageResource(R.mipmap.iv_add_choose);

                multiTv.setTextColor(ContextCompat.getColor(AddProblemNewActivity.this , R.color.text_gray_9));
                multiIv.setImageResource(R.mipmap.iv_add_no_choose);

                couponLayout.setVisibility(View.VISIBLE);
                if (null != coupon){
                    orderType = coupon.getDiscountType();
                }else{
                    orderType = ORDER_TYPE_NORMAL;
                }

                break;
            case R.id.MultiLayout:

                if (teachTimeType == TEACH_NOW){
                    showToast(getString(R.string.order_now_can_not_invite));
                }else{
                    teachType = TYPE_MULTI;

                    oneByOneTv.setTextColor(ContextCompat.getColor(AddProblemNewActivity.this , R.color.text_gray_9));
                    oneByOneIv.setImageResource(R.mipmap.iv_add_no_choose);

                    multiTv.setTextColor(ContextCompat.getColor(AddProblemNewActivity.this , R.color.common_app_color));
                    multiIv.setImageResource(R.mipmap.iv_add_choose);

                    couponLayout.setVisibility(View.GONE);
                    orderType = ORDER_TYPE_NORMAL;
                    //保存当前订单信息，推送给邀请的人

                    if (subjectId == 0){
                        showToast(getString(R.string.please_select_subject));
                    }else if (Validators.isEmpty(contentEt.getText().toString()) && Validators.isEmpty(imgList)){
                        showToast(getString(R.string.please_add_content));
                    }else if (teachTimeType == TEACH_ORDER && Validators.isEmpty(answerTime)){
                        showToast(getString(R.string.please_select_teach_time));
                    }else{
                        askProblem();
                    }
                }


                break;
            case R.id.teacherLayout:
                ChooseTeachDialog dialog = new ChooseTeachDialog(AddProblemNewActivity.this, new ChooseTeachDialog.OnTagClickListener() {
                    @Override
                    public void onClick(Dialog dialog, IdNameBean idNameBean) {
                        teacherNameTv.setText(idNameBean.getName());
                        requiredTeacherType = idNameBean.getId();
                    }
                });
                dialog.show();

                dialog.setTagSelect(requiredTeacherType);
                break;
            case R.id.askLayout:
                if (subjectId == 0){
                    showToast(getString(R.string.please_select_subject));
                }else if (Validators.isEmpty(contentEt.getText().toString()) && Validators.isEmpty(imgList)){
                    showToast(getString(R.string.please_add_content));
                }else if (teachTimeType == TEACH_ORDER && Validators.isEmpty(answerTime)){
                    showToast(getString(R.string.please_select_teach_time));
                }else{
                    if (teachTimeType == TEACH_NOW && hasOrderNow){
                        Toast.makeText(this, "您当前有正在进行中的即时订单，不可以再发布即时订单", Toast.LENGTH_LONG).show();
                    }else{
                        askProblem();
                    }
                }
                break;
            case R.id.couponLayout:
                Intent couponSelectIntent = new Intent();
                couponSelectIntent.setClass(this , CouponSelectActivity.class);
                couponSelectIntent.putExtra(CouponSelectActivity.PARAM_SELECT_COUPON , JSON.toJSONString(coupon));
                startActivityForResult(couponSelectIntent , REQUEST_CODE_COUPON);
                break;
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        PictureFileUtils.deleteCacheDirFile(AddProblemNewActivity.this);
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (resultCode == RESULT_OK) {
            switch (requestCode) {
                case PictureConfig.CHOOSE_REQUEST:
                    pathList.clear();
                    pathList.addAll(PictureSelector.obtainMultipleResult(data));

                    imgList.clear();
                    for (LocalMedia localMedia : pathList) {
                        imgList.add(localMedia.getCompressPath());
                    }

                    recyclerView.getAdapter().notifyDataSetChanged();

                    if (imgList.size() == 3){
                        addIv.setVisibility(View.GONE);
                    }else{
                        addIv.setVisibility(View.VISIBLE);
                    }
                    break;
                case REQUEST_CODE_COUPON:
                    String couponResultStr = data.getStringExtra(CouponSelectActivity.PARAM_COUPON_RESULT);

                    if (!Validators.isEmpty(couponResultStr)){
                        coupon = JSON.parseObject(data.getStringExtra(CouponSelectActivity.PARAM_COUPON_RESULT) , CouponListResult.Coupon.class);

                        orderType = coupon.getDiscountType();
                        couponTv.setText(coupon.getCouponName());
                    }else{
                        coupon = null;

                        orderType = ORDER_TYPE_NORMAL;
                        couponTv.setText("共" + couponCount + "张优惠券可用");
                    }

                    break;
            }
        }
    }

    /**提问
     *
     */
    private void askProblem(){

        if (orderType == ORDER_TYPE_NORMAL){
            //账户余额比对，如果少于60元,提示去充值
            String amount = SPUtil.getTotalAmount();
            if (!Validators.isEmpty(amount)){
                try {
                    double totalMoney = Double.parseDouble(amount);
                    if (totalMoney < 60){
                        MaterialDialogUtil.getCommonDialog(this, "提示", "您的账户余额不够支付本次提问，请充值后再提问！"
                                , "确定", "取消"
                                , new MaterialDialogUtil.OnDialogPoNeClickListener() {
                                    @Override
                                    public void onPositive() {
                                        intentActivity(RechargeActivity.class);
                                    }

                                    @Override
                                    public void onNegative() {

                                    }
                                }).show();
                    }else{
                        LoadingDialog.show(AddProblemNewActivity.this);
                        if (!Validators.isEmpty(imgList)){
                            uploadPic();
                        }else{
                            saveOrderInfo();
                        }
                    }
                } catch (NumberFormatException e) {
                    e.printStackTrace();
                }
            }
        }else{
            LoadingDialog.show(AddProblemNewActivity.this);
            if (!Validators.isEmpty(imgList)){
                uploadPic();
            }else{
                saveOrderInfo();
            }
        }

    }

    /**
     * 滚轮选择
     *
     * @param pickerList
     * @param selectItem
     */
    private void showWheelPicker(final List<IdNameBean> pickerList, final IdNameBean selectItem) {
        List<String> showList = new ArrayList<>();
        int selectPosition = 0;
        for (int i = 0; i < pickerList.size(); i++) {
            showList.add(pickerList.get(i).getName());
            if (null != selectItem){
                if (selectItem.getIdStr().equals(pickerList.get(i).getIdStr())) {
                    selectPosition = i;
                }
            }
        }
        OptionsPickerView pvOptions = new OptionsPickerBuilder(AddProblemNewActivity.this, new OnOptionsSelectListener() {
            @Override
            public void onOptionsSelect(int options1, int option2, int options3, View v) {
                //返回的分别是三个级别的选中位置
                timeClockIv.setVisibility(View.VISIBLE);
                teachTimeTv.setText(pickerList.get(options1).getName());
                answerTime = pickerList.get(options1).getIdStr();

                if(Validators.isEmpty(answerTime)){
                    teachTimeType = TEACH_NOW;


                    oneByOneTv.setTextColor(ContextCompat.getColor(AddProblemNewActivity.this , R.color.common_app_color));
                    oneByOneIv.setImageResource(R.mipmap.iv_add_choose);

                    multiTv.setTextColor(ContextCompat.getColor(AddProblemNewActivity.this , R.color.text_gray_9));
                    multiIv.setImageResource(R.mipmap.iv_add_no_choose);
                }else{
                    teachTimeType = TEACH_ORDER;
                }

            }
        }).setSubmitColor(ContextCompat.getColor(this , R.color.common_app_color))
                .setCancelColor(ContextCompat.getColor(this , R.color.text_gray_6)).build();
        pvOptions.setPicker(showList);

        if (null != selectItem) {
            pvOptions.setSelectOptions(selectPosition);
        }
        pvOptions.show();
    }

    /**获取距现在某一小时的时刻
     *
     * @return
     */
    public static List<IdNameBean> getTimeList(){
        List<IdNameBean> timeList = new ArrayList<>();
        //添加第一个即时
        IdNameBean nowNameBean = new IdNameBean();
        nowNameBean.setIdStr("");
        nowNameBean.setName("即问");
        timeList.add(nowNameBean);

        SimpleDateFormat df = new SimpleDateFormat("MM月dd日 HH点mm分");
        Calendar c = Calendar.getInstance(); // 当时的日期和时间
        int orginalDay = c.get(Calendar.DAY_OF_YEAR);

        int min = c.get(Calendar.MINUTE);
        if (min < 15){
            c.set(Calendar.MINUTE, 15);
        }else if (min > 15 && min < 30){
            c.set(Calendar.MINUTE, 30);
        }else if (min > 30 && min < 45){
            c.set(Calendar.MINUTE, 45);
        }else{
            c.set(Calendar.HOUR , c.get(Calendar.HOUR) + 1);
            c.set(Calendar.MINUTE , 0);
        }

        c.set(Calendar.MINUTE , c.get(Calendar.MINUTE) + 15);

        IdNameBean idNameBean = new IdNameBean();
        idNameBean.setIdStr(String.valueOf(c.getTime().getTime()));
        idNameBean.setName(df.format(c.getTime()));
        timeList.add(idNameBean);

        boolean add = true;
        while (add){
            int currentDay = c.get(Calendar.DAY_OF_YEAR);
            if (orginalDay == currentDay){
                c.set(Calendar.MINUTE, c.get(Calendar.MINUTE) + 15);

                IdNameBean data = new IdNameBean();
                data.setIdStr(String.valueOf(c.getTime().getTime()));
                data.setName(df.format(c.getTime()));

                timeList.add(data);

            }else{
                add = false;
            }
        }
        return timeList;
    }

    /**上传图片并保存
     *
     */
    private void uploadPic(){
        ImageUtil.upLoadImgs(imgList, new ImageUtil.ImgUpLoadListener() {
            @Override
            public void OnSuccess(String successUrl) {

            }

            @Override
            public void OnError(String message) {

            }

            @Override
            public void OnListUpSuccess(List<String> successFileList) {
                questionImages = Constant.listToString(successFileList);
                LogUtil.e("图片地址"  , questionImages);
                saveOrderInfo();
            }
        });
    }

    /**保存订单信息
     *
     */
    private void saveOrderInfo(){
        Map<String, String> map = new HashMap<>();
        map.put("creatorId" , SPUtil.stringOut(SPConstant.USER_ID));
        map.put("questionIntroduction" , contentEt.getText().toString());
        map.put("questionImages" , questionImages);
        //回答方式，即时，预约
        map.put("answerType" , teachTimeType + "");
        if (teachTimeType == TEACH_ORDER){
            map.put("answerTime" , answerTime);
        }
        map.put("gradeLevel" , SPUtil.intOut(SPConstant.SELECT_GRADE) + "");//年级
        map.put("subjectId" , subjectId + "");//学科
        map.put("groupId" , groupId);//群组
        map.put("teachingType" , teachType + "");//群组

        map.put("requiredTeacherType" , requiredTeacherType + "");//老师类型
        //如果有指定教师就传指定教师
        if (!Validators.isEmpty(appointTeacherId)){
            map.put("appointTeacherId" , appointTeacherId);
        }

        map.put("orderType" , orderType + "");
        //普通订单不传优惠券
        if (orderType != ORDER_TYPE_NORMAL){
            if (null != coupon){
                map.put("couponId" , coupon.getId() + "");
            }else{
                map.put("couponId" , "");
            }
        }


        Observable observable = ApiFactory.getEducationApiSingleton().saveOrderInfo(SPUtil.stringOut(SPConstant.TOKEN) , map);
        HttpUtil.getInstance().toSubscribe(observable, new ProgressSubscriber<SaveOrderResult>(this) {
            @Override
            protected void _onNext(SaveOrderResult saveOrderResult) {

                String orderId  = saveOrderResult.getOrderId();
                if (teachType == TYPE_ONE_BY_ONE){
                    IndexActivity.tab2checked = true;
                    CourseFragment.fragment1Checked =true;

                    EventBus.getDefault().post(CourseListFragment.REFRESH_COURSE_LIST);
                    LoadingDialog.dismiss(AddProblemNewActivity.this);
                    finish();
                }else{
                    TogetherListActivity.startTogetherActivity(AddProblemNewActivity.this , answerTime , System.currentTimeMillis(),  groupId , orderId);
                    finish();
                }
            }

            @Override
            protected void _onError(String message) {
                showToast(message);
                LoadingDialog.dismiss(AddProblemNewActivity.this);
            }
        }, ActivityLifeCycleEvent.DESTROY, lifecycleSubject,false);
    }

    /**启动该页面
     *
     * @param context
     */
    public static void startAddProblemNewActivity(Context context ,String groupId, int couponCount , boolean hasOrderNow
            , String couponStr ,  String appointTeacherId){
//        Intent intent = new Intent();
//        intent.setClass(context , AddProblemNewActivity.class);
//        intent.putExtra(PARAM_GROUP_ID , groupId);
//        intent.putExtra(PARAM_COUPON_COUNT , couponCount);
//        intent.putExtra(PARAM_APPOINT_TEACHER_ID , appointTeacherId);
//        intent.putExtra(PARAM_HAS_ORDER_NOW , hasOrderNow);
////        intent.putExtra(PARAM_IMG_PATH_LIST , pathList);
//        intent.putExtra(PARAM_COUPON , couponStr);
//
//        context.startActivity(intent);
        AddProblemActivity.startAddProblemActivity(context , groupId, couponCount, hasOrderNow, couponStr,appointTeacherId);
    }
}
